package com.ming.multifunction.service;

import com.ming.multifunction.model.domain.User;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ming.multifunction.model.request.UpdateUserRequest;
import com.ming.multifunction.model.request.UserRegisterRequest;
import com.ming.multifunction.model.vo.UserVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 用户服务
 */
public interface UserService extends IService<User> {


    /**
     * 用户注册
     * @param registerRequest
     * @param request
     * @return
     */
    long doRegister(UserRegisterRequest registerRequest, HttpServletRequest request);
    /**
     * 用户登录
     *
     * @param userAccount  用户账户
     * @param userPassword 用户密码
     * @param request
     * @return 脱敏后的用户信息
     */
    User userLogin(String userAccount, String userPassword, HttpServletRequest request);

    /**
     * 用户脱敏
     *
     * @param originUser
     * @return
     */
    User getSafetyUser(User originUser);

    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    int userLogout(HttpServletRequest request);



    /**
     * 更新用户
     *
     * @param user
     * @param loginUser
     * @return
     */
    int updateUser(UpdateUserRequest user, User loginUser);

    /**
     * 是否为管理员
     *
     * @param request
     * @return
     */
    boolean isAdmin(HttpServletRequest request);

    /**
     *
     * @param loginUser
     * @return
     */
    boolean isAdmin(User loginUser);

    /**
     * 获取当前登录用户
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);

    /**
     * 生成QQ邮箱验证码
     * @param request
     * @return
     */
    String randomCode(HttpServletRequest request);

    List<UserVO> searchUser(String searchText);
}